﻿namespace WMS6.SQLServerDAL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Data.SqlClient;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.DBUtility;
    using WMS6.IDAL;
    using WMS6.QueryEntity;

    public class FilterConfigDetailDA : IFilterConfigDetailDA
    {
        private string AND_OR = "@AND_OR";
        private string ASC_DESC = "@ASC_DESC";
        private string ATTRIBUTE = "@ATTRIBUTE";
        private string CREATED_BY = "@CREATED_BY";
        private string DESCR = "@DESCR";
        private string FILTER_NAME = "@FILTER_NAME";
        private string FILTER_STATEMENT = "@FILTER_STATEMENT";
        private string IS_ACTIVE = "@IS_ACTIVE";
        private string LEFT_PAREN = "@LEFT_PAREN";
        private string LINE_ID = "@LINE_ID";
        private string LITERAL_VALUE = "@LITERAL_VALUE";
        private string OPERAND = "@OPERAND";
        private string RECORD_TYPE = "@RECORD_TYPE";
        private string RIGHT_PAREN = "@RIGHT_PAREN";
        private string SQL_CHECK_FILTER_CONFIG_DETAIL_ID_UNIQUE = " SELECT COUNT(1) FROM @_@FILTER_CONFIG_DETAIL WHERE FILTER_NAME = @FILTER_NAME ";
        private string SQL_CHECK_FILTER_ORDER_BY_ID_UNIQUE = " SELECT COUNT(1) FROM @_@FILTER_ORDER_BY WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME AND LINE_ID = @LINE_ID ";
        private string SQL_CHECK_FILTER_STATEMENT_ID_UNIQUE = " SELECT COUNT(1) FROM @_@FILTER_STATEMENT WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME AND LINE_ID = @LINE_ID ";
        private string SQL_DELETE_FILTER_CONFIG_DETAIL = " DELETE FROM @_@FILTER_CONFIG_DETAIL WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME ";
        private string SQL_DELETE_FILTER_ORDER_BY = " DELETE FROM @_@FILTER_ORDER_BY WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME";
        private string SQL_DELETE_FILTER_STATEMENT = " DELETE FROM @_@FILTER_STATEMENT WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME ";
        private string SQL_INSERT_FILTER_CONFIG_DETAIL = " INSERT INTO @_@FILTER_CONFIG_DETAIL ( WH_ID, RECORD_TYPE, FILTER_NAME, DESCR, FILTER_STATEMENT, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, IS_ACTIVE, SYSTEM_CREATED, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @RECORD_TYPE, @FILTER_NAME, @DESCR, @FILTER_STATEMENT, @UDF1, @UDF2, @UDF3, @UDF4, @UDF5, @UDF6, @UDF7, @UDF8, @UDF9, @UDF10, @IS_ACTIVE, @SYSTEM_CREATED, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_INSERT_FILTER_ORDER_BY = " INSERT INTO @_@FILTER_ORDER_BY ( WH_ID, RECORD_TYPE, FILTER_NAME, LINE_ID, ATTRIBUTE, OPERAND, ASC_DESC, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @RECORD_TYPE, @FILTER_NAME, @LINE_ID, @ATTRIBUTE, @OPERAND, @ASC_DESC, @UDF1, @UDF2, @UDF3, @UDF4, @UDF5, @UDF6, @UDF7, @UDF8, @UDF9, @UDF10, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_INSERT_FILTER_STATEMENT = " INSERT INTO @_@FILTER_STATEMENT ( WH_ID, RECORD_TYPE, FILTER_NAME, LINE_ID, ATTRIBUTE, OPERAND, LITERAL_VALUE, AND_OR, LEFT_PAREN, RIGHT_PAREN, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES ( @WH_ID, @RECORD_TYPE, @FILTER_NAME, @LINE_ID, @ATTRIBUTE, @OPERAND, @LITERAL_VALUE, @AND_OR, @LEFT_PAREN, @RIGHT_PAREN, @UDF1, @UDF2, @UDF3, @UDF4, @UDF5, @UDF6, @UDF7, @UDF8, @UDF9, @UDF10, @CREATED_BY, GETDATE(), @UPDATED_BY, GETDATE() )  ";
        private string SQL_SELECT_ALL_FILTER_CONFIG_DETAIL = " SELECT  ROWID, WH_ID, RECORD_TYPE, FILTER_NAME, DESCR, FILTER_STATEMENT, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, IS_ACTIVE, SYSTEM_CREATED, TS, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE  FROM  @_@FILTER_CONFIG_DETAIL ";
        private string SQL_SELECT_ALL_FILTER_ORDER_BY = " SELECT  ROWID, WH_ID, RECORD_TYPE, FILTER_NAME, LINE_ID, ATTRIBUTE, OPERAND, ASC_DESC, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE  FROM  @_@FILTER_ORDER_BY ";
        private string SQL_SELECT_ALL_FILTER_STATEMENT = " SELECT  ROWID, WH_ID, RECORD_TYPE, FILTER_NAME, LINE_ID, ATTRIBUTE, OPERAND, LITERAL_VALUE, AND_OR, LEFT_PAREN, RIGHT_PAREN, UDF1, UDF2, UDF3, UDF4, UDF5, UDF6, UDF7, UDF8, UDF9, UDF10, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE  FROM  @_@FILTER_STATEMENT ";
        private string SQL_UPDATE_FILTER_CONFIG_DETAIL = " UPDATE @_@FILTER_CONFIG_DETAIL SET WH_ID = @WH_ID, DESCR = @DESCR, FILTER_STATEMENT = @FILTER_STATEMENT, UDF1 = @UDF1, UDF2 = @UDF2, UDF3 = @UDF3, UDF4 = @UDF4, UDF5 = @UDF5, UDF6 = @UDF6, UDF7 = @UDF7, UDF8 = @UDF8, UDF9 = @UDF9, UDF10 = @UDF10, IS_ACTIVE = @IS_ACTIVE, SYSTEM_CREATED = @SYSTEM_CREATED, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME  ";
        private string SQL_UPDATE_FILTER_ORDER_BY = " UPDATE @_@FILTER_ORDER_BY SET WH_ID = @WH_ID, ATTRIBUTE = @ATTRIBUTE, OPERAND = @OPERAND, ASC_DESC = @ASC_DESC, UDF1 = @UDF1, UDF2 = @UDF2, UDF3 = @UDF3, UDF4 = @UDF4, UDF5 = @UDF5, UDF6 = @UDF6, UDF7 = @UDF7, UDF8 = @UDF8, UDF9 = @UDF9, UDF10 = @UDF10, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME AND LINE_ID = @LINE_ID  ";
        private string SQL_UPDATE_FILTER_STATEMENT = " UPDATE @_@FILTER_STATEMENT SET WH_ID = @WH_ID, ATTRIBUTE = @ATTRIBUTE, OPERAND = @OPERAND, LITERAL_VALUE = @LITERAL_VALUE, AND_OR = @AND_OR, LEFT_PAREN = @LEFT_PAREN, RIGHT_PAREN = @RIGHT_PAREN, UDF1 = @UDF1, UDF2 = @UDF2, UDF3 = @UDF3, UDF4 = @UDF4, UDF5 = @UDF5, UDF6 = @UDF6, UDF7 = @UDF7, UDF8 = @UDF8, UDF9 = @UDF9, UDF10 = @UDF10, UPDATED_BY = @UPDATED_BY, UPDATED_DATE = GETDATE() WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME AND LINE_ID = @LINE_ID  ";
        private string SYSTEM_CREATED = "@SYSTEM_CREATED";
        private string TS = "@TS";
        private string UDF1 = "@UDF1";
        private string UDF10 = "@UDF10";
        private string UDF2 = "@UDF2";
        private string UDF3 = "@UDF3";
        private string UDF4 = "@UDF4";
        private string UDF5 = "@UDF5";
        private string UDF6 = "@UDF6";
        private string UDF7 = "@UDF7";
        private string UDF8 = "@UDF8";
        private string UDF9 = "@UDF9";
        private string UPDATED_BY = "@UPDATED_BY";
        private string WH_ID = "@WH_ID";

        public bool CheckFilterConfigDetailIDUnique(string filterConfigDetailID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@FILTER_NAME", filterConfigDetailID) };
            return (DBHelper.ExecuteScalar(CommandType.Text, this.SQL_CHECK_FILTER_CONFIG_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public bool CheckFilterConfigDetailIDUnique(DataBase dataBase, DbTransaction tran, string filterConfigDetailID, string whLoginID)
        {
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@FILTER_NAME", filterConfigDetailID) };
            return (dataBase.ExecuteScalar(tran, CommandType.Text, this.SQL_CHECK_FILTER_CONFIG_DETAIL_ID_UNIQUE.Replace("@_@", whLoginID), paras).ToString() == "1");
        }

        public int DeleteFilterConfigDetail(DataBase dataBase, DbTransaction tran, List<string> RecordType, List<string> FilterName, string whLoginID)
        {
            int result = 0;
            try
            {
                for (int j = 0; j < RecordType.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType[j]), new SqlParameter("@FILTER_NAME", FilterName[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int DeleteFilterOrderBy(DataBase dataBase, DbTransaction tran, List<string> RecordType, List<string> FilterName, string whLoginID)
        {
            int result = 0;
            try
            {
                for (int j = 0; j < RecordType.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType[j]), new SqlParameter("@FILTER_NAME", FilterName[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_FILTER_ORDER_BY.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int DeleteFilterStatement(DataBase dataBase, DbTransaction tran, List<string> RecordType, List<string> FilterName, string whLoginID)
        {
            int result = 0;
            try
            {
                for (int j = 0; j < RecordType.Count; j++)
                {
                    SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType[j]), new SqlParameter("@FILTER_NAME", FilterName[j]) };
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_DELETE_FILTER_STATEMENT.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public DataSet GetAllFilterConfigDetail(string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID);
            return DBHelper.ExecuteDataSet(CommandType.Text, sql);
        }

        public DataSet GetAllFilterConfigDetail(DataBase dataBase, DbTransaction tran, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID);
            return dataBase.ExecuteDataSet(tran, CommandType.Text, sql);
        }

        public FilterConfigDetailInfo GetFilterConfigDetailByID(string RecordType, string FilterName, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID) + " WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType), new SqlParameter("@FILTER_NAME", FilterName) };
            FilterConfigDetailInfo filterConfigDetailInfo = null;
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                if (reader.Read())
                {
                    filterConfigDetailInfo = new FilterConfigDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["RECORD_TYPE"].ToString(), reader["FILTER_NAME"].ToString(), reader["DESCR"].ToString(), reader["FILTER_STATEMENT"].ToString(), reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["IS_ACTIVE"].ToString(), reader["SYSTEM_CREATED"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : new DateTime(), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
                }
            }
            return filterConfigDetailInfo;
        }

        public FilterConfigDetailInfo GetFilterConfigDetailByID(DataBase dataBase, DbTransaction tran, string RecordType, string FilterName, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID) + " WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType), new SqlParameter("@FILTER_NAME", FilterName) };
            FilterConfigDetailInfo filterConfigDetailInfo = null;
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            if (reader.Read())
            {
                filterConfigDetailInfo = new FilterConfigDetailInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["RECORD_TYPE"].ToString(), reader["FILTER_NAME"].ToString(), reader["DESCR"].ToString(), reader["FILTER_STATEMENT"].ToString(), reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["IS_ACTIVE"].ToString(), reader["SYSTEM_CREATED"].ToString(), (byte[]) reader["TS"], reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : new DateTime(), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : new DateTime());
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return filterConfigDetailInfo;
        }

        public DataSet GetFilterConfigDetailByQueryList(List<string> sqlWhere, FilterConfigDetailQueryEntity filterconfigdetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!filterconfigdetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, filterconfigdetailQuery.CurrentPage, filterconfigdetailQuery.PageSize, filterconfigdetailQuery.SortField, filterconfigdetailQuery.SortDirection);
            }
            return DBHelper.ExecuteDataSet(CommandType.Text, temp);
        }

        public DataSet GetFilterConfigDetailByQueryList(DataBase dataBase, DbTransaction tran, List<string> sqlWhere, FilterConfigDetailQueryEntity filterconfigdetailQuery, string whLoginID)
        {
            string temp = this.SQL_SELECT_ALL_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID);
            for (int i = 0; i < sqlWhere.Count; i++)
            {
                if (i == 0)
                {
                    temp = temp + " WHERE " + sqlWhere[i].ToString();
                }
                else
                {
                    temp = temp + " AND " + sqlWhere[i].ToString();
                }
            }
            if (!filterconfigdetailQuery.IsGetAll)
            {
                temp = PagingHelper.GetPagingSQL(temp, filterconfigdetailQuery.CurrentPage, filterconfigdetailQuery.PageSize, filterconfigdetailQuery.SortField, filterconfigdetailQuery.SortDirection);
            }
            return dataBase.ExecuteDataSet(tran, CommandType.Text, temp);
        }

        public List<FilterOrderByInfo> GetFilterOrderByByID(string RecordType, string FilterNmae, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_FILTER_ORDER_BY.Replace("@_@", whLoginID) + " WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType), new SqlParameter("@FILTER_NAME", FilterNmae) };
            List<FilterOrderByInfo> filterOrderByInfoList = new List<FilterOrderByInfo>();
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                while (reader.Read())
                {
                    DateTime CS00002;
                    FilterOrderByInfo filterOrderByInfo = null;
                    filterOrderByInfo = new FilterOrderByInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["RECORD_TYPE"].ToString(), reader["FILTER_NAME"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["ATTRIBUTE"].ToString(), reader["OPERAND"].ToString(), reader["ASC_DESC"].ToString(), reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()));
                    filterOrderByInfoList.Add(filterOrderByInfo);
                }
            }
            return filterOrderByInfoList;
        }

        public List<FilterOrderByInfo> GetFilterOrderByByID(DataBase dataBase, DbTransaction tran, string RecordType, string FilterNmae, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_FILTER_ORDER_BY.Replace("@_@", whLoginID) + " WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME AND LINE_ID = @LINE_ID  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType), new SqlParameter("@FILTER_NAME", FilterNmae) };
            List<FilterOrderByInfo> filterOrderByInfoList = new List<FilterOrderByInfo>();
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            while (reader.Read())
            {
                DateTime CS00002;
                FilterOrderByInfo filterOrderByInfo = null;
                filterOrderByInfo = new FilterOrderByInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["RECORD_TYPE"].ToString(), reader["FILTER_NAME"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["ATTRIBUTE"].ToString(), reader["OPERAND"].ToString(), reader["ASC_DESC"].ToString(), reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()));
                filterOrderByInfoList.Add(filterOrderByInfo);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return filterOrderByInfoList;
        }

        public List<FilterStatementInfo> GetFilterStatementByID(string RecordType, string FilterName, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_FILTER_STATEMENT.Replace("@_@", whLoginID) + " WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType), new SqlParameter("@FILTER_NAME", FilterName) };
            List<FilterStatementInfo> filterStatementInfoList = new List<FilterStatementInfo>();
            using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras))
            {
                while (reader.Read())
                {
                    DateTime CS00002;
                    FilterStatementInfo filterStatementInfo = null;
                    filterStatementInfo = new FilterStatementInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["RECORD_TYPE"].ToString(), reader["FILTER_NAME"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["ATTRIBUTE"].ToString(), reader["OPERAND"].ToString(), reader["LITERAL_VALUE"].ToString(), reader["AND_OR"].ToString(), (reader["LEFT_PAREN"].ToString() != "") ? int.Parse(reader["LEFT_PAREN"].ToString()) : 0, (reader["RIGHT_PAREN"].ToString() != "") ? int.Parse(reader["RIGHT_PAREN"].ToString()) : 0, reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()));
                    filterStatementInfoList.Add(filterStatementInfo);
                }
            }
            return filterStatementInfoList;
        }

        public List<FilterStatementInfo> GetFilterStatementByID(DataBase dataBase, DbTransaction tran, string RecordType, string FilterName, string whLoginID)
        {
            string sql = this.SQL_SELECT_ALL_FILTER_STATEMENT.Replace("@_@", whLoginID) + " WHERE RECORD_TYPE = @RECORD_TYPE AND FILTER_NAME = @FILTER_NAME  ";
            SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@RECORD_TYPE", RecordType), new SqlParameter("@FILTER_NAME", FilterName) };
            List<FilterStatementInfo> filterStatementInfoList = new List<FilterStatementInfo>();
            IDataReader reader = dataBase.ExecuteReader(tran, CommandType.Text, sql, paras);
            while (reader.Read())
            {
                DateTime CS00002;
                FilterStatementInfo filterStatementInfo = null;
                filterStatementInfo = new FilterStatementInfo((reader["ROWID"].ToString() != "") ? int.Parse(reader["ROWID"].ToString()) : 0, reader["WH_ID"].ToString(), reader["RECORD_TYPE"].ToString(), reader["FILTER_NAME"].ToString(), (reader["LINE_ID"].ToString() != "") ? int.Parse(reader["LINE_ID"].ToString()) : 0, reader["ATTRIBUTE"].ToString(), reader["OPERAND"].ToString(), reader["LITERAL_VALUE"].ToString(), reader["AND_OR"].ToString(), (reader["LEFT_PAREN"].ToString() != "") ? int.Parse(reader["LEFT_PAREN"].ToString()) : 0, (reader["RIGHT_PAREN"].ToString() != "") ? int.Parse(reader["RIGHT_PAREN"].ToString()) : 0, reader["UDF1"].ToString(), reader["UDF2"].ToString(), reader["UDF3"].ToString(), reader["UDF4"].ToString(), reader["UDF5"].ToString(), reader["UDF6"].ToString(), reader["UDF7"].ToString(), reader["UDF8"].ToString(), reader["UDF9"].ToString(), reader["UDF10"].ToString(), reader["CREATED_BY"].ToString(), (reader["CREATED_DATE"].ToString() != "") ? DateTime.Parse(reader["CREATED_DATE"].ToString()) : (CS00002 = new DateTime()), reader["UPDATED_BY"].ToString(), (reader["UPDATED_DATE"].ToString() != "") ? DateTime.Parse(reader["UPDATED_DATE"].ToString()) : (CS00002 = new DateTime()));
                filterStatementInfoList.Add(filterStatementInfo);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return filterStatementInfoList;
        }

        public int InsertFilterConfigDetail(DataBase dataBase, DbTransaction tran, FilterConfigDetailInfo filterConfigDetailInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                filterConfigDetailInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_FilterConfigDetail_Parameters(filterConfigDetailInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int InsertFilterOrderBy(DataBase dataBase, DbTransaction tran, FilterOrderByInfo filterOrderByInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                filterOrderByInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_FilterOrderBy_Parameters(filterOrderByInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_FILTER_ORDER_BY.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int InsertFilterStatement(DataBase dataBase, DbTransaction tran, FilterStatementInfo filterStatementInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                filterStatementInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_FilterStatement_Parameters(filterStatementInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_INSERT_FILTER_STATEMENT.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        private SqlParameter[] Set_FilterConfigDetail_Parameters(FilterConfigDetailInfo filterConfigDetailInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { 
                new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.RECORD_TYPE, SqlDbType.VarChar, 20), new SqlParameter(this.FILTER_NAME, SqlDbType.VarChar, 20), new SqlParameter(this.DESCR, SqlDbType.VarChar, 50), new SqlParameter(this.FILTER_STATEMENT, SqlDbType.VarChar, 500), new SqlParameter(this.UDF1, SqlDbType.VarChar, 30), new SqlParameter(this.UDF2, SqlDbType.VarChar, 30), new SqlParameter(this.UDF3, SqlDbType.VarChar, 30), new SqlParameter(this.UDF4, SqlDbType.VarChar, 30), new SqlParameter(this.UDF5, SqlDbType.VarChar, 30), new SqlParameter(this.UDF6, SqlDbType.VarChar, 30), new SqlParameter(this.UDF7, SqlDbType.VarChar, 30), new SqlParameter(this.UDF8, SqlDbType.VarChar, 30), new SqlParameter(this.UDF9, SqlDbType.VarChar, 30), new SqlParameter(this.UDF10, SqlDbType.VarChar, 30), new SqlParameter(this.IS_ACTIVE, SqlDbType.VarChar, 1), 
                new SqlParameter(this.SYSTEM_CREATED, SqlDbType.VarChar, 1), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 20), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 20)
             };
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.WhID))
            {
                paramArray[0].Value = filterConfigDetailInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = filterConfigDetailInfo.RecordType;
            paramArray[2].Value = filterConfigDetailInfo.FilterName;
            paramArray[3].Value = filterConfigDetailInfo.Descr;
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.FilterStatement))
            {
                paramArray[4].Value = filterConfigDetailInfo.FilterStatement;
            }
            else
            {
                paramArray[4].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf1))
            {
                paramArray[5].Value = filterConfigDetailInfo.Udf1;
            }
            else
            {
                paramArray[5].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf2))
            {
                paramArray[6].Value = filterConfigDetailInfo.Udf2;
            }
            else
            {
                paramArray[6].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf3))
            {
                paramArray[7].Value = filterConfigDetailInfo.Udf3;
            }
            else
            {
                paramArray[7].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf4))
            {
                paramArray[8].Value = filterConfigDetailInfo.Udf4;
            }
            else
            {
                paramArray[8].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf5))
            {
                paramArray[9].Value = filterConfigDetailInfo.Udf5;
            }
            else
            {
                paramArray[9].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf6))
            {
                paramArray[10].Value = filterConfigDetailInfo.Udf6;
            }
            else
            {
                paramArray[10].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf7))
            {
                paramArray[11].Value = filterConfigDetailInfo.Udf7;
            }
            else
            {
                paramArray[11].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf8))
            {
                paramArray[12].Value = filterConfigDetailInfo.Udf8;
            }
            else
            {
                paramArray[12].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf9))
            {
                paramArray[13].Value = filterConfigDetailInfo.Udf9;
            }
            else
            {
                paramArray[13].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterConfigDetailInfo.Udf10))
            {
                paramArray[14].Value = filterConfigDetailInfo.Udf10;
            }
            else
            {
                paramArray[14].Value = DBNull.Value;
            }
            paramArray[15].Value = filterConfigDetailInfo.IsActive;
            paramArray[0x10].Value = filterConfigDetailInfo.SystemCreated;
            paramArray[0x11].Value = filterConfigDetailInfo.CreatedBy;
            paramArray[0x12].Value = filterConfigDetailInfo.UpdatedBy;
            return paramArray;
        }

        private SqlParameter[] Set_FilterOrderBy_Parameters(FilterOrderByInfo filterOrderByInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { 
                new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.RECORD_TYPE, SqlDbType.VarChar, 20), new SqlParameter(this.FILTER_NAME, SqlDbType.VarChar, 20), new SqlParameter(this.LINE_ID, SqlDbType.Int, 4), new SqlParameter(this.ATTRIBUTE, SqlDbType.VarChar, 100), new SqlParameter(this.OPERAND, SqlDbType.VarChar, 200), new SqlParameter(this.ASC_DESC, SqlDbType.VarChar, 20), new SqlParameter(this.UDF1, SqlDbType.VarChar, 30), new SqlParameter(this.UDF2, SqlDbType.VarChar, 30), new SqlParameter(this.UDF3, SqlDbType.VarChar, 30), new SqlParameter(this.UDF4, SqlDbType.VarChar, 30), new SqlParameter(this.UDF5, SqlDbType.VarChar, 30), new SqlParameter(this.UDF6, SqlDbType.VarChar, 30), new SqlParameter(this.UDF7, SqlDbType.VarChar, 30), new SqlParameter(this.UDF8, SqlDbType.VarChar, 30), new SqlParameter(this.UDF9, SqlDbType.VarChar, 30), 
                new SqlParameter(this.UDF10, SqlDbType.VarChar, 30), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 20), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 20)
             };
            if (!string.IsNullOrEmpty(filterOrderByInfo.WhID))
            {
                paramArray[0].Value = filterOrderByInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = filterOrderByInfo.RecordType;
            paramArray[2].Value = filterOrderByInfo.FilterName;
            paramArray[3].Value = filterOrderByInfo.LineID;
            if (!string.IsNullOrEmpty(filterOrderByInfo.Attribute))
            {
                paramArray[4].Value = filterOrderByInfo.Attribute;
            }
            else
            {
                paramArray[4].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Operand))
            {
                paramArray[5].Value = filterOrderByInfo.Operand;
            }
            else
            {
                paramArray[5].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.AscDesc))
            {
                paramArray[6].Value = filterOrderByInfo.AscDesc;
            }
            else
            {
                paramArray[6].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf1))
            {
                paramArray[7].Value = filterOrderByInfo.Udf1;
            }
            else
            {
                paramArray[7].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf2))
            {
                paramArray[8].Value = filterOrderByInfo.Udf2;
            }
            else
            {
                paramArray[8].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf3))
            {
                paramArray[9].Value = filterOrderByInfo.Udf3;
            }
            else
            {
                paramArray[9].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf4))
            {
                paramArray[10].Value = filterOrderByInfo.Udf4;
            }
            else
            {
                paramArray[10].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf5))
            {
                paramArray[11].Value = filterOrderByInfo.Udf5;
            }
            else
            {
                paramArray[11].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf6))
            {
                paramArray[12].Value = filterOrderByInfo.Udf6;
            }
            else
            {
                paramArray[12].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf7))
            {
                paramArray[13].Value = filterOrderByInfo.Udf7;
            }
            else
            {
                paramArray[13].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf8))
            {
                paramArray[14].Value = filterOrderByInfo.Udf8;
            }
            else
            {
                paramArray[14].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf9))
            {
                paramArray[15].Value = filterOrderByInfo.Udf9;
            }
            else
            {
                paramArray[15].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterOrderByInfo.Udf10))
            {
                paramArray[0x10].Value = filterOrderByInfo.Udf10;
            }
            else
            {
                paramArray[0x10].Value = DBNull.Value;
            }
            paramArray[0x11].Value = filterOrderByInfo.CreatedBy;
            paramArray[0x12].Value = filterOrderByInfo.UpdatedBy;
            return paramArray;
        }

        private SqlParameter[] Set_FilterStatement_Parameters(FilterStatementInfo filterStatementInfo)
        {
            SqlParameter[] paramArray = new SqlParameter[] { 
                new SqlParameter(this.WH_ID, SqlDbType.VarChar, 30), new SqlParameter(this.RECORD_TYPE, SqlDbType.VarChar, 20), new SqlParameter(this.FILTER_NAME, SqlDbType.VarChar, 20), new SqlParameter(this.LINE_ID, SqlDbType.Int, 4), new SqlParameter(this.ATTRIBUTE, SqlDbType.VarChar, 100), new SqlParameter(this.OPERAND, SqlDbType.VarChar, 200), new SqlParameter(this.LITERAL_VALUE, SqlDbType.VarChar, 20), new SqlParameter(this.AND_OR, SqlDbType.VarChar, 3), new SqlParameter(this.LEFT_PAREN, SqlDbType.Int, 4), new SqlParameter(this.RIGHT_PAREN, SqlDbType.Int, 4), new SqlParameter(this.UDF1, SqlDbType.VarChar, 30), new SqlParameter(this.UDF2, SqlDbType.VarChar, 30), new SqlParameter(this.UDF3, SqlDbType.VarChar, 30), new SqlParameter(this.UDF4, SqlDbType.VarChar, 30), new SqlParameter(this.UDF5, SqlDbType.VarChar, 30), new SqlParameter(this.UDF6, SqlDbType.VarChar, 30), 
                new SqlParameter(this.UDF7, SqlDbType.VarChar, 30), new SqlParameter(this.UDF8, SqlDbType.VarChar, 30), new SqlParameter(this.UDF9, SqlDbType.VarChar, 30), new SqlParameter(this.UDF10, SqlDbType.VarChar, 30), new SqlParameter(this.CREATED_BY, SqlDbType.VarChar, 20), new SqlParameter(this.UPDATED_BY, SqlDbType.VarChar, 20)
             };
            if (!string.IsNullOrEmpty(filterStatementInfo.WhID))
            {
                paramArray[0].Value = filterStatementInfo.WhID;
            }
            else
            {
                paramArray[0].Value = DBNull.Value;
            }
            paramArray[1].Value = filterStatementInfo.RecordType;
            paramArray[2].Value = filterStatementInfo.FilterName;
            paramArray[3].Value = filterStatementInfo.LineID;
            if (!string.IsNullOrEmpty(filterStatementInfo.Attribute))
            {
                paramArray[4].Value = filterStatementInfo.Attribute;
            }
            else
            {
                paramArray[4].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Operand))
            {
                paramArray[5].Value = filterStatementInfo.Operand;
            }
            else
            {
                paramArray[5].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.LiteralValue))
            {
                paramArray[6].Value = filterStatementInfo.LiteralValue;
            }
            else
            {
                paramArray[6].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.AndOr))
            {
                paramArray[7].Value = filterStatementInfo.AndOr;
            }
            else
            {
                paramArray[7].Value = DBNull.Value;
            }
            paramArray[8].Value = filterStatementInfo.LeftParen;
            paramArray[9].Value = filterStatementInfo.RightParen;
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf1))
            {
                paramArray[10].Value = filterStatementInfo.Udf1;
            }
            else
            {
                paramArray[10].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf2))
            {
                paramArray[11].Value = filterStatementInfo.Udf2;
            }
            else
            {
                paramArray[11].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf3))
            {
                paramArray[12].Value = filterStatementInfo.Udf3;
            }
            else
            {
                paramArray[12].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf4))
            {
                paramArray[13].Value = filterStatementInfo.Udf4;
            }
            else
            {
                paramArray[13].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf5))
            {
                paramArray[14].Value = filterStatementInfo.Udf5;
            }
            else
            {
                paramArray[14].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf6))
            {
                paramArray[15].Value = filterStatementInfo.Udf6;
            }
            else
            {
                paramArray[15].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf7))
            {
                paramArray[0x10].Value = filterStatementInfo.Udf7;
            }
            else
            {
                paramArray[0x10].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf8))
            {
                paramArray[0x11].Value = filterStatementInfo.Udf8;
            }
            else
            {
                paramArray[0x11].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf9))
            {
                paramArray[0x12].Value = filterStatementInfo.Udf9;
            }
            else
            {
                paramArray[0x12].Value = DBNull.Value;
            }
            if (!string.IsNullOrEmpty(filterStatementInfo.Udf10))
            {
                paramArray[0x13].Value = filterStatementInfo.Udf10;
            }
            else
            {
                paramArray[0x13].Value = DBNull.Value;
            }
            paramArray[20].Value = filterStatementInfo.CreatedBy;
            paramArray[0x15].Value = filterStatementInfo.UpdatedBy;
            return paramArray;
        }

        public int UpdateFilterConfigDetail(FilterConfigDetailInfo filterConfigDetailInfo, string whLoginID)
        {
            int result = 0;
            DataBase db = new DataBase();
            DbConnection conn = db.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                filterConfigDetailInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_FilterConfigDetail_Parameters(filterConfigDetailInfo);
                if (paras != null)
                {
                    result += db.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID), paras);
                }
                tran.Commit();
            }
            catch (SqlException sqlEx)
            {
                tran.Rollback();
                conn.Close();
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int UpdateFilterConfigDetail(DataBase dataBase, DbTransaction tran, FilterConfigDetailInfo filterConfigDetailInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                filterConfigDetailInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_FilterConfigDetail_Parameters(filterConfigDetailInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_FILTER_CONFIG_DETAIL.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int UpdateFilterOrderBy(DataBase dataBase, DbTransaction tran, FilterOrderByInfo filterOrderByInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                filterOrderByInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_FilterOrderBy_Parameters(filterOrderByInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_FILTER_ORDER_BY.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }

        public int UpdateFilterStatement(DataBase dataBase, DbTransaction tran, FilterStatementInfo filterStatementInfo, string whLoginID)
        {
            int result = 0;
            try
            {
                filterStatementInfo.WhID = whLoginID;
                SqlParameter[] paras = this.Set_FilterStatement_Parameters(filterStatementInfo);
                if (paras != null)
                {
                    result += dataBase.ExecuteNonQuery(tran, CommandType.Text, this.SQL_UPDATE_FILTER_STATEMENT.Replace("@_@", whLoginID), paras);
                }
            }
            catch (SqlException sqlEx)
            {
                CommonErrorHandler.ErrorHandler(sqlEx, LogType.Error);
            }
            return result;
        }
    }
}

